Our company website is hosted on our infrastructure and external user can access it OK. However, when I try to access from our intranet, some CSS and JS files always take exactly 2 minutes to download, blocking site load until completely download, and it happens always with the same files. Even I add the entire URL of them in the firewall's whitelist, this behavior is the same. If I access the file, and I could reproduce this scenario (see this image). What do I need to setup in the firewall to resolve this problem?
Some tips for faster loading CSS/JS
- Wherever possible try to load your JS files just before your closing
</body>tag. This makes it so the page can start displaying before your JS finishes loading.
asyncJS loading. If the JS is a file that takes a very long time or is a big download it might be a candidate for loading
asyncinstead. Here's some info on how to use optimizely to do asynchronous JS loading. If that JS is needed right away you still have to solve that issue but at least you could use async in the meantime while you work out the details.
- Put public assets in your root web directory
- Minify your CSS and JS code where applicable
- Serve assets over a CDN (Content Delivery Network) so the files load from someone else's servers, which most typically is faster and more reliable. If you're using a common library asset like jQuery, you can find them already uploaded to a CDN and freely usable. Just insert something like this just before your closing
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>. Here's where I got that CDN link info.
Also, here at least one StackOverflow question that might be helpful.