JSFiddle - React, Tailwind, and code Playground

JavaScript

var w = 500;
var h = 300;
$(function() {
	var c = $('<canvas>').appendTo('body');
	c.width( w ).attr('width', w);
	c.height( h ).attr('height', h);
	update();
});

function update()
{
	var c = $('canvas')[0].getContext('2d');

    c.fillStyle = '#000';
	c.fillRect(0, 0, w, h);

    var sinT = Math.abs( Math.sin((new Date).getTime()/1000) );
    c.lineWidth = 0.1 +  sinT*15;
    c.strokeStyle = '#fff';
    c.fillStyle = '#000';
    c.font = '20px Arial';

    var s = 'How to prevent ugly spikes?';
    var x = w/2 - c.measureText(s).width/2;
    var y = h/2;
    c.strokeText(s, x, y);
    c.fillText(s, x, y);

	setTimeout(update, 50);
}