On a well-designed site, (publicly accessible) URLs will not change. Of course, you can freely use any internal structure.
If necessary, you should be able to generate JS just like you create HTML. However, if you apply the correct REST principles :
API REST - URI () , (.. , , API). , , .
, , , , XPath jQuery, , DOM , .