Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By espirates on
With cache turned on css and js get placed into their own separate files except this code
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "basePath": "/", "cron": { "basePath": "/poormanscron", "runNext": 1264889434 }, "extlink": { "extTarget": "_blank", "extClass": "ext", "extSubdomains": 1, "extExclude": "", "extInclude": "", "extAlert": 0, "extAlertText": "This link will take you to an external web site. We are not responsible for their content.", "mailtoClass": "mailto" } });
//--><!]]>
</script>
Is it really necessary to have this inside the page or can it be cached like the other js ?
Comments
I assume you mean
I assume you mean "optimization", not caching.
Some javascript data may change from user to user, or based on other contexts. That data cannot be put in per-page aggregated .js file, so it goes in CDATA.
Short answer: no.
I suppose there may be some
I suppose there may be some module that would put this CDATA section in a sepatate .js file on the fly, but I'm not aware of it if there is one.
A module like this would be
A module like this would be great! This type of thing is a no no for SEO. It pushes your real content that much further down in the code. Here's my CDATA... this is insane:
As above - the data that is
As above - the data that is pushed into the header there may be different per-page, per-user, per-sessions. It is entirely dynamic and unsuited to putting in an external js file.
It has absolutely nothing to do with SEO myths.
It has a tiny bit to do with page size, but an external js file which is unique for every single request would hurt and slow down page performance significantly.
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Subscribing, can somebody
Subscribing, can somebody confirm that a large CDATA piece in source code like above can not hurt SEO rankings please?
EDIT: This helped me: http://drupal.org/node/286653#comment-2318052. This puts the code on the footer of the page, which is better I think.
Thanks a lot in advance,
greetings,
Martijn
The way I did it in D7
The way I did it in D7 is:
in
/includes/common.inc
I commented out$output .= theme('html_tag', array('element' => $js_element));
on line 4158. so it went from this:to this:
Of course, it's like messing with the core so be careful, and it would be nice if there was a way to do it through template.php
UPDATE:
This seemed to work in my template.php file.
Thank you
the hook worked fine for me
Simply removing the
Simply removing the javascript like this breaks any functions or effects that rely on that javascript, i.e. drop down menus etc.
Are you sure you want to sacrifice your jQuery?
Drupal Web Designers Surrey South East England www.lightflows.co.uk
Not neccessary
Just in case any noobs run across this post:
Leave this alone! The CDATA jQuery.extend code is maybe 2KB of data and it is inline (no extra http request). It has nothing to do with SEO performance, if you think it does prove it. If you are worrying about SEO, stop.
If you are worrying about performance, maybe you should try optimizing some images instead, using image sprites or or setting up a CDN. Go run Google PageSpeed or YSlow for Firebug, and it will tell you what to do.
-----------------------------------------------
The Future is Open!
It's not about SEO, it's
It's not about SEO, it's about keeping the source clean and also removing any Drupal indicators which can be a target by spambots. There's really no reason this should be visible in the source code. That's one of the things I liked about Modx, the source would show nothing but css, very clean, just the way I like it.
In drupal 7 we have in
In drupal 7 we have in header
And tell to the all spammers in the world - came in :) we are Drupal site with all knowing issue
i have CDATA of css, that is
i have CDATA of css, that is messing up the display of the site -- -anyway to alter the hook to apply it to css?
Hi,Is there a easy way to
Hi,
Is there a easy way to get rid of:
It also messes up Analytics...
EDIT: I found: http://www.benmarshall.me/remove-type-attribute-drupal-7/
greetings, Martijn