How to determine if a javascript was already loaded by other html file

后端 未结 3 2047
小蘑菇
小蘑菇 2021-01-22 23:43

How to determine if a javascript was already loaded by other html file? I want to reduce the redundant loading of the javascript files to decrease the loading time of my webpage

3条回答
  •  Happy的楠姐
    2021-01-23 00:13

    If you want to prevent the files from being downloaded twice then this will be automatic provided they are set to be cacheable (most webservers should set these headers sensibly by default).

    If you want to make sure that the include tag happens only once when including files in a dynamic language then you will need some sort of manager. ASP.NET provides a scriptmanager class that does this (among other things). I cannot speak for other languages and frameworks

提交回复
热议问题