2. Build Configuration < Previous Page
In order to support older browsers, polyfills that enable technologied required
by the slider mechanism must be loaded. If you don't use any polyfill loader
in your project, use polyfills.js
file provided by HyperText Slider.
'use strict';
require('hyper-text-slider/lib/polyfills');
Slider's scripting API is quite rich, but all we need is upgrading the slider, which will be declared on our web page.
var htSlider = require('hyper-text-slider');
window.addEventListener('load', function() {
htSlider.boot(document.body);
});
Above script loads hyper-text-slider
module and calls boot
function after page loads.
We'll also use Google Fonts to load Roboto into our webpage.
window.WebFontConfig = {
google: { families: [ 'Roboto:thin' ] },
};
(function() {
var wfs = document.createElement('script');
wfs.src = (document.location.protocol === 'https:'? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1.5.18/webfont.js';
wfs.type = 'text/javascript';
wfs.async = 'true';
var script = document.getElementsByTagName('script')[0];
script.parentNode.insertBefore(wfs, script);
}());
As resources loaded by our web page are quite heavy (CSS, JavaScipt and images),
flash of unstyled content (FOUC) may occur.
To deal with this problem we will add js
class name on <html>
element.
This class will be styled in CSS (see 5.5. Page Visibility).
document.documentElement.classList.add('js');
Next Page > 4. HTML Page