I am working on a webpage ,on which I need to fetch around 10 external .js files.So browser makes 10 requests to fetch them. Is there any way which I can bring all of them in one shot??
Is there any way I come bring all of them in One shot??
No, but you can bundle and compress them all into one single JS
file.
That would save you the total round-trips time consumption for the all 10 files.
You can use online tools to achieve it easily, like: http://jscompress.com/
First of all - if browser gets all 10 JS files, they will be stored in cache, so next request will load files from cache.
About merging files into one - you can create some script which will fetch all 10 files, merge their content and save in a specified file. Or do it by your own if JS files are static.
You can try these
Comments and whitespace are not needed for javascript execution; Removing them will speed up script execution times
OR
If possible, you can execute the script asynchronously. HTML5 has got this feature. <script>
tag has got async
boolean property. make use of it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.