Dual java scripts in head

Discussion in 'HTML & Website Design' started by captainron19, Sep 9, 2015.

  1. #1
    Is it possible to have 2 javascripts in the "head" tags?

    When I put them in both my scripts stop working.

    I have 2 scripts to run on a specific page.....
    1. Slideshow for the top
    2. Image viewer for photos

    You can see an example here... http://trentonems.com/staff.php of it not allowing the sideshow to start (just hangs up at first photo) and the thumbnail viewer is not opening up the thumbnails properly into their full size

    Here is the code I am using
    <head>
      <title>Trenton EMS</title>
    <meta name="Description" content="Trenton Emergency Medical Service is located in the Capital City of Trenton in NJ and provides emergency medical care to the residents and visitors to the city of Trenton">
    <meta name="KeyWords" content="tems,trenton,emergency,medical,service,ems,nj,new jersey">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <link rel="stylesheet" type="text/css" href="css/style.css" />
      <link rel="stylesheet" href="image_viewer/lightbox.css" type="text/css" media="screen" />
    <script type="text/javascript" src="image_viewer/js/prototype.js"></script>
    <script type="text/javascript" src="image_viewer/js/scriptaculous.js?load=effects"></script>
    <script type="text/javascript" src="image_viewer/js/lightbox.js"></script>
    
    
        <script type="text/javascript" src="js/jquery.min.js"></script>
      <script type="text/javascript" src="js/jquery.easing.min.js"></script>
      <script type="text/javascript" src="js/jquery.nivo.slider.pack.js"></script>
      <script type="text/javascript">
        $(window).load(function() {
            $('#slider').nivoSlider();
        });
        </script>
    
    </head>
    Code (markup):

     
    Last edited: Sep 9, 2015
    captainron19, Sep 9, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    You're using different libraries., which often lead to such problems. I suggest trying to use only one library, and then find plugins that does what you want.
     
    PoPSiCLe, Sep 9, 2015 IP
    deathshadow likes this.
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,808
    Likes Received:
    4,535
    Best Answers:
    123
    Trophy Points:
    665
    #3
    If you view the source of any large website you'll see that they have lots of javascript files listed in their head section - you've got 6 in your example.

    My concern is that you have 3 scripts all trying to do the same thing
    1. prototype
    2. scriptaculous
    3. jquery
    Pick a library and stick to it.

    I'm guessing you've been trawling the web for things that do what you want and then nobbling them all together. Time to get serious and tidy up your site, do some decent programming and avoid the conflicts between the js libraries.
     
    sarahk, Sep 9, 2015 IP
  4. COBOLdinosaur

    COBOLdinosaur Active Member

    Messages:
    515
    Likes Received:
    123
    Best Answers:
    11
    Trophy Points:
    95
    #4
    Welcome to Jquery crap central. A big issues with jquery is that there are zero recognized standards, so conflicts and compatibility issues are common. If you don't have the skills to go into the jquery script and modify the code causing the problem, then you really should not be using third party jquery files that you cannot evaluate prior to using them. 10-15% of jquery plugins contain malware
    If you are not capable of fixing the jquery yourself, you might want to see if you can get help from the support page of the place where you got the plugins though very few purveyors of jquey trash collections actually provide any support.
     
    COBOLdinosaur, Sep 9, 2015 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Or none whatsoever since they're bloated BS that typically let people add crap to websites that have no damned business on websites in the first place.

    See 90%+ of "slideshow" style effects that are little more than a waste of bandwidth, waste of screen space, piss off users trying to find actual content, and more often than not are used to fill up screen space to hide a lack of actual content of value.

    Christmas on a cracker you're loading six malfing scripts for what? A crappy lightbox effect that shouldn't even take more than 5k of scripting, and some stupid slideshow? Plow that. Much less good scripts should be able to be loaded AFTER the content in BODY so they can start loading faster/sooner.

    Admittedly I say the same thing about multiple stylesheets and <style> tags without media targets...

    That whole page though being a laundry list of how not to build a website with it's endless pointless DIV for nothing, endless pointless classes and ID for NOTHING, tables for layout, breaks doing padding's job, paragraphs wrapping non-paragraph content, zero keywords relevance, tags like CENTER that have zero business on any website written after 1997, clearing breaks like it's still 2001, gibberish use of vertical breaks, copyright copyright, presentational images in the markup, gibberish use of headings, non real-world deployable doctype, lack of alt text on EVERY image, closing tags for anchors that aren't even open, etc, etc...

    Normally you'd think at 3.83k it would be impossible for it to be a bloated mess... but, well.... about a third of that belongs on the cutting room floor.
     
    deathshadow, Sep 10, 2015 IP