When you need a quick cross-browser compatible hand, don't bang your head. HeadJS is here to help you out !
- Speed up your apps: Load JS & CSS asyncronously and in parallel, but execute them in order
- Load one asset if a condition is met, else fallback and load a different one
- Manage script dependencies, and execute callbacks once they are loaded
- Cross-browser compatible « pseudo media-queries » let you code against different resolutions & devices
- Fix quirks in specific browsers by quickly applying dedicated CSS/JS logic
- Detect various browsers & their versions
- Check if the client supports a certain Browser, HTML5, or CSS3 feature
- Automatically generates JS and CSS classes for browsers & features that where detected
- Automatically generates CSS classes, to know what page or section a user is viewing
- Know if the user is in landscape or portrait mode
- Or whether the client is using a mobile or desktop device
- Get old browsers to support HTML5 elements like nav, sidebar, header, footer, ...
- ...
-
Make it, The only script in your <HEAD>
- A concise solution to universal problems
Your imagination, Your limit
Responsive Design (Think @media-queries, and more)
Need to display an element at a specific screen size ?
/* JS */
if (head.screen.innerWidth > 800) {
document.getElementById("#side-menu").style.display = "block";
}
/* CSS */
.gt-800 #side-menu {
display: block;
}
As you can see above, if you can write it in CSS, you can usually also write it in JavaScript.
Feature Detections (Like Modernizr. Just smaller, and simpler)
What about custom detections and device/browser features ?
/* Add a custom feature yourself */
head.feature("member", true);
/* Now use it */
if (head.member) {
document.querySelector(".member-menu").style.display = "block";
}
.member-menu {
display: block;
}
/* Use built-in detections*/
/* if the browser supports CSS3 box-shadow */
if (head.boxshadow) {
document.querySelector(".member-menu").style.boxShadow = "3px 3px 3px black";
}
/* if the browser supports CSS3 box-shadow */
.boxshadow .member-menu {
box-shadow: 3px 3px 3px black;
}
We have a bunch of features detections built in, and if that's not enough, simply create one yourself !
- Desktop
- Mobile
- Landscape
- Portrait
- Retina
- Touch
- Transitions
- Transforms
- Gradients
- Opacity
- Textshadow
- Multiplebgs
- Boxshadow
- Borderimage
- Borderradius
- Cssreflections
- Fontface
- rgba()
Resource Loading (Direct or Conditional)
Need to quickly load a JS or CSS file ?
// Load up some JS
head.load("jQuery.js", function() {
// Call a function when done
console.log("Done loading jQuery");
});
// Load up some CSS
head.load("bootstrap.css");
How about something crazy like
On DocumentReady, if the user is using IE8, you need to load 2 scripts, or otherwise load a different script, then wait for them to finish loading, then fire a callback, and then load/apply a stylesheet ? Yeah right..
Easy.
// head.ready(document, callback)
// head.test(test, success, failure, callback)
head.ready(document, function() {
head.test(
(head.browser.ie && head.browser.version === 8),
["file1.js", "file2.js"],
["other.js"],
function() {
// run callback
head.load("file1.css");
}
);
});
Of course you can use each of those functions (ready, test, load) individually too.



