Sometimes small items takes too much of time. I always face issues when it comes to providing correct location of the resource so this post is an effort to minimize such issues.
Let’s understand differences in which resources are referenced. Consider the index.html has script in below ways:
- Browser will look in the current directly of the file where this script tag is mentioned. So if you move the index.html into any other directly then browser will not be able to reference the myscript.js
- This will be exactly same as example in #1. This is only different way of mentioning that refer the file from the current directory.
- Here browser will look into the root directory of the website, no matter where the index.html having this tag is present.
- Here browser will go to the parent directory of the index.html and then will look for the myscript.js
This blog post is small but thought of sharing, whenever I used to face issue then I used to try different formats and some or the other used to work. Never paid close attention but if you have so many file references and then your try outs permutation and combination increases. Having clear understanding of how references work would save some hassles.