#1
  1. No Profile Picture
    Super Moderator
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,502
    Rep Power
    111

    Combining/Cleaning up a header...


    I'm pretty much helping a friend with a site, and am bringing a script he created on Weebly and cleaning it up. I mostly have 2 questions.
    1st is joining the multiple <script> groups together, since a couple seem to have open elements in each, and I'm not sure if I'm to just connect them as-if the </script><script> didn't exist, or end each one in some manner.
    Code:
        <script>_W.relinquish && _W.relinquish()</script>
        <script> _W.themePlugins = [];</script>
    2nd is in relation to the parenthesis wrapping the outer function, as well as the following (window._W && _W.jQuery). What does this do? Is it best/favored any other way?
    Original:
    Code:
    	<head>
    		<title>First Nich - Home</title><meta property="og:site_name" content="First Nich" />
    <meta property="og:title" content="First Nich" />
    <meta property="og:description" content="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec..." />
    <meta property="og:image" content="http://trainingsiteweebly.weebly.com/uploads/7/5/8/5/75856337/5903909.jpg?242" />
    <meta property="og:image" content="http://trainingsiteweebly.weebly.com/uploads/7/5/8/5/75856337/1552564_orig.png" />
    <meta property="og:image" content="http://trainingsiteweebly.weebly.com/uploads/7/5/8/5/75856337/7209758.jpg?429" />
    <meta property="og:image" content="http://trainingsiteweebly.weebly.com/uploads/7/5/8/5/75856337/329446_orig.jpg" />
    <meta property="og:image" content="http://trainingsiteweebly.weebly.com/uploads/7/5/8/5/75856337/6914932_orig.jpg" />
    <meta property="og:image" content="http://trainingsiteweebly.weebly.com/uploads/7/5/8/5/75856337/85309.jpg?470" />
    <meta property="og:image" content="http://trainingsiteweebly.weebly.com/uploads/7/5/8/5/75856337/9511924_orig.jpg" />
    <meta property="og:url" content="http://trainingsiteweebly.weebly.com/" />
    
    
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0;">
    
    		
    		<link id="wsite-base-style" rel="stylesheet" type="text/css" href="//cdn2.editmysite.com/css/sites.css?buildTime=1458255195" />
    <link rel="stylesheet" type="text/css" href="//cdn1.editmysite.com/editor/libraries/fancybox/fancybox.css?1458255195" />
    <link rel="stylesheet" type="text/css" href="//cdn2.editmysite.com/css/social-icons.css?buildtime=1458255195" media="screen,projection" />
    <link rel="stylesheet" type="text/css" href="/files/main_style.css?1458318169" title="wsite-theme-css" />
    <link href='//fonts.googleapis.com/css?family=Lato:400,300,300italic,700,400italic,700italic&subset=latin,latin-ext' rel='stylesheet' type='text/css' />
    <link href='//fonts.googleapis.com/css?family=Montserrat:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css' />
    		<script><!--
    var STATIC_BASE = '//cdn1.editmysite.com/';
    var STYLE_PREFIX = 'wsite';
    //-->
    </script>
    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
    
    <script type="text/javascript" src="//cdn2.editmysite.com/js/lang/en/stl.js?buildTime=1458255195&"></script>
    <script src="//cdn2.editmysite.com/js/site/main.js?buildTime=1458255195"></script><script type="text/javascript">_W.configDomain = "www.weebly.com";</script><script>_W.relinquish && _W.relinquish()</script>
    <script type="text/javascript" src="//cdn2.editmysite.com/js/lang/en/stl.js?buildTime=1458255195&"></script><script> _W.themePlugins = [];</script><script type="text/javascript"><!--
    	
    	
    	(function(jQuery){
    		function initFlyouts(){
    			initPublishedFlyoutMenus(
    				[{"id":"112857691414556045","title":"Home","url":"index.html","target":""},{"id":"165720749375396510","title":"Services","url":"services.html","target":""},{"id":"649094178301882549","title":"About","url":"about.html","target":""},{"id":"323491866581157724","title":"Contact","url":"contact.html","target":""}],
    				"112857691414556045",
    				'',
    				'active',
    				false,
    				{"navigation\/item":"<li {{#id}}id=\"{{id}}\"{{\/id}}\n\tclass=\"wsite-menu-item-wrap\"\n\t>\n\t<a href=\"{{url}}\"\n\t\t{{#target}}target=\"{{target}}\"{{\/target}}\n\t\tclass=\"wsite-menu-item\"\n\t\t{{#membership_required}}\n\t\t\tdata-membership-required=\"{{.}}\"\n\t\t{{\/membership_required}}\n\t\t>\n\t\t{{{title_html}}}\n\t<\/a>\n\t{{#has_children}}{{> navigation\/flyout\/list}}{{\/has_children}}\n<\/li>\n","navigation\/flyout\/list":"<div class=\"wsite-menu-wrap\" style=\"display:none\">\n\t<ul class=\"wsite-menu\">\n\t\t{{#children}}{{> navigation\/flyout\/item}}{{\/children}}\n\t<\/ul>\n<\/div>\n","navigation\/flyout\/item":"<li {{#id}}id=\"{{id}}\"{{\/id}}\n\tclass=\"wsite-menu-subitem-wrap {{#is_current}}wsite-nav-current{{\/is_current}}\"\n\t>\n\t<a href=\"{{url}}\"\n\t\t{{#target}}target=\"{{target}}\"{{\/target}}\n\t\tclass=\"wsite-menu-subitem\"\n\t\t>\n\t\t<span class=\"wsite-menu-title\">\n\t\t\t{{{title_html}}}\n\t\t<\/span>{{#has_children}}<span class=\"wsite-menu-arrow\">&gt;<\/span>{{\/has_children}}\n\t<\/a>\n\t{{#has_children}}{{> navigation\/flyout\/list}}{{\/has_children}}\n<\/li>\n"},
    				{}
    			)
    		}
    		if (jQuery) {
    			jQuery(document).ready(function() { jQuery(initFlyouts); });
    		}else{
    			if (Prototype.Browser.IE) window.onload = initFlyouts;
    			else document.observe('dom:loaded', initFlyouts);
    		}
    	})(window._W && _W.jQuery)
    //-->
    </script>
    		
    	</head>
    Edited:
    Code:
    <head>
      <title>First Nich - Home</title>
      <meta property="og:site_name" content="First Nich" />
      <meta property="og:title" content="First Nich" />
      <meta property="og:description" content="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec..." />
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <meta name="viewport" content="width=device-width, initial-scale=1.0;">
      <link id="wsite-base-style" rel="stylesheet" type="text/css" href="//cdn2.editmysite.com/css/sites.css?buildTime=1458255195" />
      <link rel="stylesheet" type="text/css" href="//cdn1.editmysite.com/editor/libraries/fancybox/fancybox.css?1458255195" />
      <link rel="stylesheet" type="text/css" href="//cdn2.editmysite.com/css/social-icons.css?buildtime=1458255195" media="screen,projection" />
      <link rel="stylesheet" type="text/css" href="/files/main_style.css?1458318169" title="wsite-theme-css" />
      <link href='//fonts.googleapis.com/css?family=Lato:400,300,300italic,700,400italic,700italic&subset=latin,latin-ext' rel='stylesheet' type='text/css' />
      <link href='//fonts.googleapis.com/css?family=Montserrat:400,700&subset=latin,latin-ext' rel='stylesheet' type='text/css' />
      <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
      <script src="//cdn2.editmysite.com/js/site/main.js?buildTime=1458255195"></script>
      <script type="text/javascript" src="//cdn2.editmysite.com/js/lang/en/stl.js?buildTime=1458255195&"></script>
      <script>
        <!--
          var STATIC_BASE = '//cdn1.editmysite.com/';
          var STYLE_PREFIX = 'wsite';
        //-->
      </script>
      <script>_W.relinquish && _W.relinquish()</script>
      <script> _W.themePlugins = [];</script>
      <script type="text/javascript">
        <!--
          (function(jQuery) {
            function initFlyouts() {
              initPublishedFlyoutMenus(
                [{"id":"112857691414556045","title":"Home","url":"index.html","target":""},{"id":"165720749375396510","title":"Services","url":"services.html","target":""},{"id":"649094178301882549","title":"About","url":"about.html","target":""},{"id":"323491866581157724","title":"Contact","url":"contact.html","target":""}],
                "112857691414556045",
                '',
                'active',
                false,
                {"navigation\/item":"<li {{#id}}id=\"{{id}}\"{{\/id}}\n\tclass=\"wsite-menu-item-wrap\"\n\t>\n\t<a href=\"{{url}}\"\n\t\t{{#target}}target=\"{{target}}\"{{\/target}}\n\t\tclass=\"wsite-menu-item\"\n\t\t{{#membership_required}}\n\t\t\tdata-membership-required=\"{{.}}\"\n\t\t{{\/membership_required}}\n\t\t>\n\t\t{{{title_html}}}\n\t<\/a>\n\t{{#has_children}}{{> navigation\/flyout\/list}}{{\/has_children}}\n<\/li>\n","navigation\/flyout\/list":"<div class=\"wsite-menu-wrap\" style=\"display:none\">\n\t<ul class=\"wsite-menu\">\n\t\t{{#children}}{{> navigation\/flyout\/item}}{{\/children}}\n\t<\/ul>\n<\/div>\n","navigation\/flyout\/item":"<li {{#id}}id=\"{{id}}\"{{\/id}}\n\tclass=\"wsite-menu-subitem-wrap {{#is_current}}wsite-nav-current{{\/is_current}}\"\n\t>\n\t<a href=\"{{url}}\"\n\t\t{{#target}}target=\"{{target}}\"{{\/target}}\n\t\tclass=\"wsite-menu-subitem\"\n\t\t>\n\t\t<span class=\"wsite-menu-title\">\n\t\t\t{{{title_html}}}\n\t\t<\/span>{{#has_children}}<span class=\"wsite-menu-arrow\">&gt;<\/span>{{\/has_children}}\n\t<\/a>\n\t{{#has_children}}{{> navigation\/flyout\/list}}{{\/has_children}}\n<\/li>\n"}
              )
            }
            if(jQuery) {
              jQuery(document).ready(function() { jQuery(initFlyouts); });
            } else {
              if(Prototype.Browser.IE) window.onload = initFlyouts;
              else document.observe('dom:loaded', initFlyouts);
            }
          })(window._W && _W.jQuery)
        //-->
      </script>
    </head>
    Last edited by Triple_Nothing; May 15th, 2016 at 11:48 AM.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
  2. #2
  3. Maddening Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,453
    Rep Power
    9645
    1. You can connect them just fine. There's no real significance in the <script> blocks themselves.
    Code:
        <script>_W.relinquish && _W.relinquish();_W.themePlugins = [];</script>
    2. You mean the outer parentheses in
    Code:
    (function(){...})(args)
    That's how you create an anonymous function and call it at the same time. The parentheses are required because Javascript syntax doesn't allow for writing
    Code:
    function(){...}(args)
  4. #3
  5. No Profile Picture
    Super Moderator
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,502
    Rep Power
    111
    Thank you very much.

    Since the original is written the way it is, does it truly get interpreted as you presented with the added semi-colon, or more like:
    Code:
    <script>_W.relinquish && _W.relinquish() _W.themePlugins = [];</script>
    Or does a closing </script> tag define a semi-colon or such if one does not exist?

    Original:
    Code:
        <script>_W.relinquish && _W.relinquish()</script>
        <script> _W.themePlugins = [];</script>
    Last edited by Triple_Nothing; May 15th, 2016 at 06:01 PM.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
  6. #4
  7. Maddening Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,453
    Rep Power
    9645
    Originally Posted by Triple_Nothing
    Since the original is written the way it is, does it truly get interpreted as you presented with the added semi-colon, or more like:
    Code:
    <script>_W.relinquish && _W.relinquish() _W.themePlugins = [];</script>
    Or does a closing </script> tag define a semi-colon or such if one does not exist?
    The closing tag will also finish off any unterminated statement. So the semicolon is implied.

    Comments on this post

    • Triple_Nothing agrees : Thanks! ;)

IMN logo majestic logo threadwatch logo seochat tools logo