/* global kirkiWebfonts, WebFont */

// Asyncronously add webfontloader.
( function( document ) {
	var wf      = document.createElement( 'script' ),
	    scripts = document.scripts[0];

	wf.src   = 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
	wf.id    = 'webfontloader',
	wf.async = true;

	scripts.parentNode.insertBefore( wf, scripts );
} )( document );

jQuery( document ).ready( function() {
	var script  = document.querySelector( '#webfontloader' ),
	    subsets = ['cyrillic', 'cyrillic-ext', 'devanagari', 'greek', 'greek-ext', 'khmer', 'latin', 'latin-ext', 'vietnamese', 'hebrew', 'arabic', 'bengali', 'gujarati', 'tamil', 'telugu', 'thai'];

	// Check when the webfontloader finishes loading.
	script.addEventListener( 'load', function() {

		// Loop fonts.
		_.each( kirkiWebfonts, function( weights, family ) {

			// Add font.
			WebFont.load( {
				google:{
					families: [ family + ':' + weights.join( ',' ) + subsets.join( ',' ) ]
				}
			} );
		} );
	} );
} );

@@ -96,19 +96,20 @@
  %7B%0A%09
-var wf     
+let wfScript
  = d
@@ -156,16 +156,17 @@
 scripts 
+ 
 = docume
@@ -184,16 +184,22 @@
 0%5D;%0A%0A%09wf
+Script
 .src   =
@@ -269,16 +269,22 @@
 js';%0A%09wf
+Script
 .id    =
@@ -303,13 +303,19 @@
 der'
-,
+;
 %0A%09wf
+Script
 .asy
@@ -362,16 +362,22 @@
 fore( wf
+Script
 , script
@@ -443,11 +443,11 @@
  %7B%0A%09
-var
+let
  scr
@@ -499,204 +499,8 @@
 r' )
-,%0A%09    subsets = %5B'cyrillic', 'cyrillic-ext', 'devanagari', 'greek', 'greek-ext', 'khmer', 'latin', 'latin-ext', 'vietnamese', 'hebrew', 'arabic', 'bengali', 'gujarati', 'tamil', 'telugu', 'thai'%5D
 ;%0A%0A%09
@@ -776,27 +776,140 @@
 ) + 
-subsets.join( ',' )
+'cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai'
  %5D%0A%09

simplify code