Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I evaluated this module for a project which requires IE 7 compatibility, but chose to use a homebrew module instead. Reasoning being, because my theme already has its own html.tpl.php
it seems a little clunky to add a new variable to my theme's template, especially since that amounts to a new module dependency.
Would it be better to add the link to html5.js using drupal_add_html_head()
? E.g.:
$element = array(
'#tag' => 'script',
'#prefix' => '<!--[if lt IE 9]>',
'#attributes' => array(
'src' => '...module path...html5.js',
'type' => 'text/javascript',
),
'#suffix' => '</script><![endif]-->',
);
drupal_add_html_head($element, 'rbn_html5_shiv');
That way even if this module's template file isn't used, you can get the shiv right outta the box?
Comments
Comment #1
ericduran CreditAttribution: ericduran commentedhmm, I don't see why not.
I remember there was a reason why we didn't do this at 1st, but I'll look into it.
Of the top of my head here some issues that come to me:
- This is going to cause the script to be entire before the css, which isn't bad but performance wise it should be after.
- This is going to cause the script to be enter before the other script tags. This is normally not a problem if you're only using the shiv but if you're only using the shiv you might have other problems with ajax. If you notice our script has a couple of extras such as overwriting the Drupal.ajax.prototype.commands.insert function.
So yea, these are problem the reason why drupal_add_html_head my not work. But I'll double check all my theories
Comment #2
ericduran CreditAttribution: ericduran commentedOk, well I removed the innershiv and the hack to use innershiv with drupal ajax insert method.
I guess now we can actually make this work without having to required people to change the html template.
I still don't like using the drupal_add_html_head. I wish there was another way :-( sadly we've been done this road multiple times. So we'll see.
Comment #3
ericduran CreditAttribution: ericduran commentedComment #4
ericduran CreditAttribution: ericduran commentedComment #5
ericduran CreditAttribution: ericduran commentedActually I think we should just remove all this.
People should honestly be using modernizr for loading the shiv.
Comment #6
ericduran CreditAttribution: ericduran commentedComment #7
ericduran CreditAttribution: ericduran commentedThis is now fixed.
The html5.js is no longer included in this module. Everyone should really use modernizr or include the scripts them self in they're themes html.tpl.php.
--
http://drupalcode.org/project/html5_tools.git/commit/ee994a7
Comment #9
pobster CreditAttribution: pobster commentedYou missed a bit...
Pobster
Comment #10
seandunaway CreditAttribution: seandunaway commentedFor your consideration :)
I think the simple shiv *should* be optionally included via this module.
Perhaps a simple radio option on the settings page (None, Google's, or Local). Additionally we could add a description/link for modernizr.
This is *the* html5 module, which "html5izes Drupal core" - surely the globally accepted required shiv should be included as an option so it just works :)
HTML5 is already scary enough to implement for many users, I'd hate for them to get this module and not be familiar with how to make it work a very real market share. Also, for people like me, who don't find modernizr all that particularly helpful, when we have conditional styles and doctype declarations at the top of every theme, and who don't care to use the modernizr module, to download the nearly empty customized package with shiv only, and install and configure with libraries module dependency, etc.
If you're open to this let me know I can roll a patch today.
Comment #11
ruplAbsolutely not, please do not put Modernizr in this module.
I am doing great things over at http://drupal.org/project/modernizr if I may say so myself. Check out the 7.x-3.x branch. Things are much improved over older versions. html5_tools could even integrate with the Modernizr module to keep the shiv out of your Modernizr build if you have html5_tools enabled. I'll write the hook for html5_tools if needed, it's no sweat!
Comment #12
seandunaway CreditAttribution: seandunaway commentedrupl, I meant link to your module. :)
Comment #13
ruplAh my mistake!
My offer still stands to write the html5_tools integration for the Modernizr Drupal API once we get to a more stable release.
Comment #14
ericduran CreditAttribution: ericduran commentedWell what I do is just include the shiv in the modernizr build and it's honestly what most people should be doing.
Which is one of the reasons why we got rid of it from here.
I'm more than happy to make it conditional. But I really think we should just push people to use modernizr instead and include the shiv in it.
Comment #15
ericduran CreditAttribution: ericduran commentedAlso another reason is that is mis-leading. Because technically we can't force it on other people if they're using a custom theme.
This really has to be a conscious effort on the developer/themer.
Comment #16
seandunaway CreditAttribution: seandunaway commentedericduran made some valid points on IRC and convinced me. :)
Restoring the status that I disrupted. :)