SSAgov / ANDI

A tool to test web content for accessibility and 508 compliance.
https://www.ssa.gov/accessibility/andi/help/howtouse.html
Other
293 stars 75 forks source link

It would be nice if andi.js was smaller #148

Open ollie-iterators opened 1 year ago

ollie-iterators commented 1 year ago

I think it would be better for the code if one were able to split up the different modules in the code of andi.js (Like AndiOverlay, Utility, ...) so that it would be easier to understand the code and try to fix it.

JohnCotterSSA commented 1 year ago

100% true, and definitely something I've wanted. I couldn't find an easy way to make the js compile together at runtime. Do you have a suggestion on how to do this?

ollie-iterators commented 1 year ago

One suggestion I found was that you could include each of the files you want to use as script tags.

JohnCotterSSA commented 1 year ago

That's a lot of trips to the server. Concerned it would reduce load speed.

ollie-iterators commented 1 year ago

Here is an example repository about JavaScript modules: https://github.com/mdn/js-examples/tree/master/module-examples

ollie-iterators commented 1 year ago

I have mostly finished the work that is needed for my branch of code that is about putting the andi objects code into different files and exporting them to where they are needed to run the program.

I only have 1 error that keeps coming up when I use the branch. It says for the modules (fandi.js, gandi.js, ...) that "import declarations may only appear at the top level of a module". NOTE: This error does not cause the code to fail, or cause any issues. It just shows up in the console.

One thing that I had to do was to change the init_module functions so that they started with the first letter of the modules (cinit_module for candi.js, finit_module for fandi.js, ...) because I had to export init_module to andi.js and eventually andiModule.js for it to work because importing something with the same name multiple times from different files does not work with JavaScript.

ollie-iterators commented 1 year ago

@JohnCotterSSA, I used the code in this repository: https://github.com/mdn/js-examples as a way to learn about exporting code into other files using JavaScript.

ollie-iterators commented 1 year ago

If you are worried about load speed, you could check out some things to improve the speed of the JavaScript code