Posts

Showing posts from November, 2024

Removing whitespace in JavaScript strings used for dynamic CSS

Image
 I remove excess whitespace in strings used to create dynamic CSS. My minimiser, 'UglifyJS', does not remove the excess whitespace. It would be quite difficult.  So, I edit the source file by hand in 'vi' saying:     s:'[ ][ ]*:' :g This turns:     ' @keyframes ppbWingRight' + birdNumber + ' { ' +     '   0% { ' +     '     transform: rotate3d(0,1,0,' + wingAngle + 'deg); ' +     '   } ' +     '   100% { ' +     '     transform: rotate3d(0,1,0,-' + wingAngle + 'deg); ' +     '   } ' +     ' } ' + into:            ' @keyframes ppbWingRight' + birdNumber + ' { ' +     ' 0% { ' +     ' transform: rotate3d(0,1,0,' + wingAngle + 'deg); ' +     ' } ' +     ' 100% { ' +     ' transform: rotate3d(0,1,0,-' + wingAngle + 'deg); ' +     ' } ' +     ' } ' + I create a 'style' tag, set the '