5 Replies Latest reply on Apr 28, 2013 9:04 PM by sudarshan.t

    import a javascript??


      Hi I really need to know if its possible to import a .js to a new html page like you would a .css, if yes, HOW?

      Could someone please help? I spent all day all this, I am ither really dumb or really blind.

        • 1. Re: import a javascript??
          Mike M Level 6

          Put this in your code in the <head> section:


          <script type="text/javascript" src="put the location of the source file here"></script>


          Some people like to add language="javascript" too but it isn't an absolute necessity.

          1 person found this helpful
          • 2. Re: import a javascript??
            sudarshan.t Level 6

            @TheirRno....: CF solution will work. But depending on what type of .js file you're trying to incorporate, you could either load it within your <head> section or anywhere towards the very bottom of your page before closing </body> tag. The difference is pageload times. Javascript calls at the very bottom will load your actual webpage much faster. Again, this may not work at all times. If your webpage uses a certain function that is controlled using a .js file, that file may need to be loaded in <head> tag.


            But, if you're using a plug-in that you're trying to run only after your page completely finishes loading, these scripts can be at the very bottom.


            This is a generic structure of a HTML5 website with CSS, JS and jQuery library:


            <!doctype html>


                 <meta> <!--All metatags here-->

                 <title>Title here</title>

                 <link href="path/to/your/stylesheet.css" type="text/css"> <!--Your CSS files can be included here-->

                 <script src="path/to/your/jquery/library.js" type="text/javascript"> <!--Your jQuery library can be included at the very beginning as all jQuery plugins you'll use will rely on the library-->




            <script src="path/to/your/plugin.js" type="text/javascript"> <!--Your plugins can be loaded here so the webpage loads faster-->




            And like CF says, the type definition is not necessary, but is definitely recommended to ensure browsers dont go into 'quirks' mode. Also to make your webpage W3 compliant.

            • 3. Re: import a javascript??
              Nancy OShea Adobe Community Professional & MVP
              1 person found this helpful
              • 4. Re: import a javascript??
                TheirRNoavailableESC Level 1

                dreamwevaer made me java, when I made a responsive html and it keeps giving me errors when I try to add it but thanks for the rest it worked thanks

                • 5. Re: import a javascript??
                  sudarshan.t Level 6

                  Java & JavaScript are like apples and oranges. 2 completely different things. What you use normally for webpages with .js extension is JavaScript.


                  when I made a responsive html and it keeps giving me errors when I try to add it

                  What errors did you get?

                  1 person found this helpful