Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transcompile jQuery to JavaScript

I know all internal jQuery functions are written in JavaScript, so it should technically be possible to just evaluate jQuery to JavaScript.

I have a snippet of JavaScript that uses jQuery that I need to use in an environment where jQuery isn't available. I know I could translate it by hand, but it is quite a lot of code. Is there a tool out that that does this?

Just to make it clear: with a lot of effort I could probably get jQuery in the environment but I would like to have a solution that is a bit more resource friendly. If there is no tool like this I'll just try to translate the code by hand, I was just wondering whether there was such a tool.

like image 846
Tim van Dalen Avatar asked Jan 25 '12 22:01

Tim van Dalen


People also ask

How do I convert ES5 to ES6?

Any ES5 code is valid ES6 code. And Babel only transpiles newer features into older equivalent code, not the other way round (detecting patterns in ES5 that could be expressed differently in ES6). You should aim to write ES6 as the source. There is no automated conversion of ES5 to ES6.

What is Babel REPL?

Babel is a free and open-source JavaScript transcompiler that is mainly used to convert ECMAScript 2015+ (ES6+) code into backwards-compatible JavaScript code that can be run by older JavaScript engines. It allows web developers to take advantage of the newest features of the language. Babel.


1 Answers

Google's Closure Compiler's advanced optimization compresses your code to only include parts that are necessary, so the parts of jQuery that aren't used are stripped away.

like image 106
Casey Chu Avatar answered Oct 09 '22 20:10

Casey Chu