Advice Generator app using Tailwind CSS
Design comparison
Solution retrospective
any suggestions are welcome... I initially put my JS in an external file but it wasn't integrating and working while deploying. There must have been an error in putting down the path. If anyone knows the solution to this, please let me know
Community feedback
- @harshitBhardwaj97Posted about 1 year ago
Initially I also faced this problem when I used external .js file in my various projects and used script tag to link it, but based on my experience, I can say that the most common problem with this approach is that when we use script tag and give the path to our file, the .js file code is executed before our DOM is even loaded, leading to this problem. So you can try these 2 approaches and I believe you won't face this problem :-
- Use defer keyword after script and before src, if you define your script path inside the head tag, like this :
(script *defer* src="index.js")(/script)
- Use the script tag at the end of body, which would ensure that all DOM content is loaded before execution of javascript code. In this case, defer keyword is not required.
Here I used () instead of angular brackets with script tag because due to it my comment was not being parsed properly.I hope you find this suggestion helpful and it solves the problem that you were facing. Happy Coding !
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord