In a Mobile Website if a JavaScript can enhance UX but will make the page little slower to load, is it ok to use javascript?
Or we should always give preference to speed specially on mobile?
In a Mobile Website if a JavaScript can enhance UX but will make the page little slower to load, is it ok to use javascript?
Or we should always give preference to speed specially on mobile?
Of course, it depends on what exactly are you enhancing and at what cost. But the ideal solution would be to load fast a minimally usable version and enhance it progressively, for example via loading Javascript on demand
Kind of impossible to say. You have to weight the advantages that the javascript gives the user to the added size of the total page. In general though - javascript is light weight and can be used to partially load data with AJAX - which in the end will make the total experience load faster.
You can also combine @vinko-vrsalovic answer with Application Cache
That way the file is only loaded at the beginning and when you update it.