I hope this question is not too general, but I did not find a good tutorial on how to make the transition from standard javascript / jQuery code to module / checked code. Mmy's new challenge is to fully refactor javascript of our wordpress plugin. Our current code is the standard jQuery code, which threw everything into a file, checking for the existence of dom elements in order to understand which page we are on and attach the correct event handlers. My goal is simply to write more convenient and understandable code and introduce tests into this process. My approach:
- Try modulating the code in separate files (one file for each page) and use require.js to load only the necessary code.
- write some tests using jasmine / silon and try to adapt this code so that the tests pass
Do you have any other suggestions / best practices? Can you talk about how you approached similar tasks?
I thought about connecting the mvc framework, but if I can stick to the standard jQuery code, I think it is easier for the development team because it does not add complexity.
source share