Convert jQuery plugin to plain javascript


I need some quick help with a jQuery + javascript task:

Essential: I want to convert the attached jQuery plugin—as well as its initialization on an HTML page—into plain javascript. I am not using jQuery for anything else on the page, so I want to reduce the weight of the code base by being able to not use jQuery at all.

Optional: If it can speed up running the script, then I need the script to be adjusted to simply check for 3 specific fonts, that should be defined in an array in the script: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", rather than checking all the fonts in the font-family (which I believe it does now).

Optional: If there is any other way to optimize the time it takes for the script to run (before the page is shown), that would be appreciated as well.

Can someone help with this?

Thank you,

// ### The jQuery Plugin ###

// See documentation on [url removed, login to view]


* Font UnStack 0.1


* Developed by Phil Oye

* Copyright (c) 2009 Phil Oye, [url removed, login to view]


* Licensed under the MIT license:

* [url removed, login to view]



(function($) {

$.[url removed, login to view] = function(opts) {

$.[url removed, login to view](opts,this);

return this;


$.fontunstack = {

options: {

prefix: "set_in_"


init: function(opts, elems){

var elems = elems || "body";

$.extend([url removed, login to view], opts);

if( [url removed, login to view] == "") {

[url removed, login to view] = "set_in_";


var stack = $(elems).css('font-family');

// If a css-style font-family declaration (string) passed in, convert to array

if (typeof stack == "string") {

stack = [url removed, login to view](/[^'",;\s][^'",;]*/g) || [];


[url removed, login to view](stack, elems);


analyzeStack: function(stack, elems) {

var generics = ["monospace", "sans-serif", "serif", "cursive", "fantasy"];

var baseline = generics[0];

var num_fonts = [url removed, login to view];

var last_resort = stack[num_fonts -1];

// If author hasn't included a generic (tsk, tsk), let's add one

if ($.inArray(last_resort, generics)) {

[url removed, login to view](baseline);



// If the generic is the same as our baseline, let's use another.

if (last_resort == baseline) {

baseline = generics[1];


// At this point we're sure there is a generic fallback font, so we'll only iterate though the non-generics.

for (var i=0; i<num_fonts -1; i++) {

font = stack[i];

if ($.[url removed, login to view](font, baseline)) {

// Remove any class that has our prefix to prevent doubles.

var re = new RegExp("\\b" + [url removed, login to view] + ".*?\\b","g");

$(elems).get(0).className = $(elems).get(0).[url removed, login to view](re, "");

// This should convert UTF8 to lowercase ANSI, removing all punctuation/spaces, but regexp scares me.

safe_font_name = encodeURIComponent( [url removed, login to view]( /[\s\-.!~*'()"]/g, "").toLowerCase() );

$(elems).addClass([url removed, login to view] + safe_font_name);

break; //We only want to find one installed font per stack.




testFont: function(requested_font, baseline_font) {

var span = $('<span id="font_tester" style="font-family:' + baseline_font + '; font-size:144px;position:absolute;left:-10000px;top:-10000px;visibility:hidden;">mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmml</span>');


var baseline_width = [url removed, login to view]();

[url removed, login to view]("font-family", requested_font + "," + baseline_font );

var requested_width = [url removed, login to view]();

[url removed, login to view]();

// If the dimensions change, the font is installed

return (requested_width != baseline_width);




// ### The initialization ###

$(document).ready(function() {



Compétences : Javascript, jQuery / Prototype

en voir plus : jmodal plugin jquery, wordpress javascript pop plugin, invoking javascript firefox plugin, yahoo javascript video plugin, zoom plugin jquery, pro tools tdmrtas plugin vst convert, javascript checking resolution jquery, wordpress javascript popup plugin, javascript text editor jquery, javascript screen height jquery, firefox cut paste javascript page plugin, image javascript popup plugin, javascript photo album jquery, javascript font resize jquery, javascript editor plugin

Concernant l'employeur :
( 1 commentaire ) Copenhagen, Denmark

Nº du projet : #12718070

Décerné à:

%selectedBids___i_sum_sub_7% %project_currencyDetails_sign_sub_8% EUR en 10 jours
(134 Commentaires)

7 freelance font une offre moyenne de €511 pour ce travail


I can do it in few hours thanks ------------------------------------------------------------------------------------------------------

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% EUR en 1 jour
(8 Commentaires)

Dear Client, Greetings from Flowgica technologies, I have experience with these skills. We do have similar experience doing something similar to yours therefore I am looking forward to discuss and move ahead. Our late Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 12 jours
(5 Commentaires)

we have Very good experience developer we will finished your task as soon as possible

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 3 jours
(8 Commentaires)

Hello, Greetings of the day With a tremendous experience of 3 years after serving the industry in various domains, Mobile App Development Company has achieved many milestones on it success path. Our expertise not Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 10 jours
(0 Commentaires)

Dear Project Owner, Greetings for the day! Thank you for reviewing my bid. I have gone through the details and will get it done quite comfortably. We have huge experience of working on JQuery and JavaS Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 20 jours
(0 Commentaires)

Hi, Greetings from Aponiar Solution Private Limited. ([url removed, login to view]) I take the privilege to introduce myself as a Sr. Full Stack Developer with 5 years of experience. I have a good amount of exposure in workin Plus

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% EUR en 10 jours
(0 Commentaires)