vendredi 29 octobre 2021

Jquery is not defined when remove "text/javascript" attribute

Scenario that works:

  • I have an APP_FRAMEWORK.JS file that was generated through a WEBPACK, including BOOTSTRAP AND JQUERY inside it.

    <script type="text/javascript" src="" defer></script>
    
    @if(!empty($assets['js']))
        @foreach ($assets['js'] as $js)
            <script type="text/javascript" src=""></script>
        @endforeach
    @endif
    

If I load the page as in the example, it works perfectly, without any errors in the scripts that are loaded inside that loop below.

My question:

  • Why, if I remove the "text/javascript" when loading the MAIN SCRIPT (APP_FRAMEWORK.JS) the $ is not defined error starts to appear?
  • Remembering that this TYPE is no longer mandatory, scripts are loaded in the correct order and there is a DEFER!!!

enter image description here enter image description here




Aucun commentaire:

Enregistrer un commentaire