Optimise JavaScript for a faster web site
Copy the contents of your file into the left hand side box, and you will get returned optimised script in the other. Perfect for transition from development to live.
About
This tool is designed to bring down the size of JavaScript files, and while this will help, it can't make decisions like what your file includes and where it should be within your site, and how you use it.
Initial coding had reductions of between 5% and 15% dependent on code styling, however in our latest update we have increased it to up to almost 25%.
We've been using this for a number of years internally, so have confidence in it, however if you find it breaks your code then please feel free to contact us.
Test JavaScript
function nextElSibling(el) {
if (el.nextSibling)
do { el = el.nextSibling } while (el && el.nodeType !== 1);
return el;
}
function prevElSibling(el) {
if (el.previousSibling)
do { el = el.previousSibling } while (el && el.nodeType !== 1);
return el;
}
function upElSibling(el) {
do { el = el.parentNode; } while (el.nodeType !== 1);
return el;
}
function upElSiblingA(el) {
try {
do { el = el.parentNode; } while (el.tagName.toLowerCase() !== "a");
return el;
}
catch (err) {
return el;
}
}
Return JavaScript
function nextElSibling(el){
if(el.nextSibling)
do {el=el.nextSibling }while (el && el.nodeType !== 1);return el;}function prevElSibling(el){
if(el.previousSibling)
do {el=el.previousSibling }while (el && el.nodeType !== 1);return el;}function upElSibling(el){
do {el=el.parentNode;}while (el.nodeType !== 1);return el;}function upElSiblingA(el){
try {
do {el=el.parentNode;}while (el.tagName.toLowerCase()!== "a");return el;}catch (err){
return el;}}