How to Remove Unused javascript From Website [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I'm trying to speed up my website. I used www.unused-css.com/ to trim away excess CSS, but I cannot find anything similar for JavaScript. Is there an online service that can detect the js code being used and then trim away the unused code?
Here is the website with the problem: IQ Tests for Kids
I'm using bootstrap code and it is very bloated. I'm sure that I'm only using a fraction of js because I trimmed down my HTML as well.

The best you are going to get is running the JavaScript itself through a dead code removal process, such as the one provided by the Google Closure Compiler with ADVANCED_OPTIMIZATIONS enabled or Uglify's dead_code option. Some people even combine both of these.
Tree shaking is an even better process you will hear people talk about. But this is more difficult to achieve in your case, because tree shaking involves using ES6 modules, which the code you are dealing with almost certainly is not. Thus it would be a lot of work to get that going, as you would have to modify the code.

Don't know any online tool for that, but there are techniques to do what is called "tree shaking". You can google about it more.
Best my used tools to have it working are webpack and Flow
Webpack is quite general tool to make all kind of magic with JS, while Flow is type checking tool which, if you have type checking active can provide very good tree shaking.
But as you mentioned, you are using Bootstrap, so best place to start looking at would be customize your build:
http://getbootstrap.com/customize/

Related

Is there a tool, program, extension to prevent and find code repetition in a project? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I've been looking for a VS Code / Git extension, add-on or anything that can help me prevent but to also identify code that is already repeated so I can abstract it away and reuse it.
You know, maybe even build a library for the darn app but I haven't found anything useful and fresh yet.
There is, but it is not free. WebStorm IDE or any there JetBrains IDE show code repetition and also give you a very good insight into your code. you can try it for free for 30 days and if you liked it then buy it.
WebStorm - The smartest JavaScript IDE
Sonarlint is one of the best tool. It says code duplications and makes sure the code is good shape based on the best practices. You can also add that as a plugin in the VS Code.
SonarCube is the actual product you are looking for, it provide lot more than code duplication details.
Sonar Cube will do following things for you
Code Quality Check, it actually analyses your entire code and provides you information about Bugs and vulnerabilities
it also provides you code coverage on new-code which get pushed
it provides you information and graphs about code coverage, bugs etc.
it provides you information about code duplication

How To Obfuscate Javascript to Unreadable, but Valid [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm soon releasing my paid Electron application.
I have worked for many months on it now, and i need protection on my source code.
i have 2 files, 1. file 5000 lines, and 2. file around 4000 lines.
I need very good obfuscation on this, so it can't be read, and cant be cracked easily.
I'm willing to pay a little bit for a good obfuscator, if anyone knows any good ones that isn't free.
I have tried some different online javascript obfuscators, and most isn't very good, and is easily to read afterwards.
Thank you.
The short and sweet is: what you're looking for does not exist.
At its core, electron is very little but a repackaged webview executing javascript/html/css. The moment you execute your application, the said webview has to have full, concurrent access to the files required by it.
This means your code is there, open, unencrypted, and the only defense you have against somebody peeking is obfuscation. Which, let's admit one thing, falls short pretty quickly when the person digging into the code knows javascript.
If you were using a framework for your app that allowed purely native code, you could write a DRM-esque toolchain for it, but sadly, that's not even an option. Beyond uglifying your code and moving as much of it towards WASM as possible, there's no real other option, just compromises and trade-offs.

Can two people work on the same javascript project simultaneously? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
me and my friend have this develop a game in 18 hour competition on friday, and we have to use javascript (I don't know why) and it isn't very pleasant to work on the same project from two computers and exchange code over a network share folder, is there any way to have a sort of Google docs for javascript coding? Where we can both edit the same document in real time from two different computers? Any time appreciated.
You're referring to "version control".
A good tool (usually the de-facto) for that is Git.
You can then push your code to something like GitHub.
Lots of stuff you can do with this... You can both have individual branches, push them to GitHub, and then "diff" them, meaning you can see individual changes line-by-line and decide what you want to keep or discard. These can be merged to, say, a master branch which represents your final product.
use some sort of source control! Github is an excellent site to use GIT with. Other options include, but are not limited to, SVN and mecurial
SVN, GitHub, TFS are good tools for source control. They will also provide you the ability to check in/check out so that things can be merged in the background. So, if you and your friend are working on the same file and both commit the changes, they would be merged together. However, if you're wanting to see your buddies changes as he types, you're going to need to write something to do this. If you want this type of functionality, there's a cool library out there called signalR (http://signalr.net/). This may be a little overkill but I don't know any text editors out there that will allow you to see someone elses changes as they type. You could probably spin something up with ajax calls but again, that would be overkill and performance would be an issue.

jQuery Plugin TDD Starting Point [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have some existing Javascript code that I'm looking to port to a jQuery plugin. The code itself is nothing complex: Flickr API photo gallery with varying photo sizes, a few other things. I coded it up quickly and it's stable enough, but I want to redo it the "right way".
I set up a simple TDD environment based off Yeoman, with Grunt and Mocha, and it works well. The problem I have is that my plugin will work like most jQuery plugins, having a simple entry point:
$( '#ele' ).myAwesomePlugin( { ... } ); // Do all the things
and I'm scratching my head at where to start writing tests. While I already have most of the code to complete the plugin, I'm trying to go through the motions of the development being driven by the tests, and I don't know how to transition from this high-level point into the smaller portions of the code.
Some stages of the program flow would be: communicate with Flickr, gather photos (or not), divide them up into various sizes, and arrange them into a container.
The plugin itself would (ideally) only have one publicly-accessible method, but, if that's the case, how should my tests hook into my deeper logic? Should I be splitting my code up into smaller, testable chunks that aren't jQuery plugins, and then combine them? I'm curious if there's a way for tests themselves to drive that development.
Any recommendations on reading material or articles would be very helpful. I'm pretty excited finally to be doing TDD!
Here is a link to test-driven-development of jquery plugins with Jasmine.
BDD Testing of jQuery plugins using Jasmine
Jasmine is similar to Mocha, so you could follow the tutorial with either Jasmine or Mocha.

Browserless, ant-task-oriented Javascript Unit Testing? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a javascript unit test framework that I can use as part of my automated maven build. This CANNOT use an actual browser, and it MUST be fully browserless.
I've tried looking at a few posts on SO, but none seem to meet my needs. Is there such a javascript unit tester? I'm anxious to find out.
I was trying to solve the same problem. It seems, that this is not as common, as one might think from our perspective.
RhinoUnit looks very good.
If you need browser capabilities within Rhino, take a look at
http://ejohn.org/blog/bringing-the-browser-to-the-server/
http://groups.google.com/group/envjs
http://github.com/thatcher/env-js/tree/master
There are two projects called JSUnit (www.jsunit.net) and (jsunit.berlios.de). The latter is designed to work with Rhino and Maven. Note that there will be browser-specific problems that such tests will not discover, but it should help with basic functionality.
Not sure about a JavaScript unit testing framework, though I'm sure there is one. But I would probably look towards Rhino as JS interpreter.
http://www.mozilla.org/rhino/
If your JS references any of the browser/DOM you'll also need to mock/stub those...
Have you tried JSunit?
AFAIK, javascript is a language specifically designed to run in the browser.
Have you considereds j-unit tests? They do still run in the browser however.

Categories

Resources