It's not a script. Cloudflare is a combination proxy server/CDN (content delivery network). It's a web service. Basically, you tell the nice people who run the DNSs to lok for your site at Cloudflare instead of where it really lives. Cloudflare gets the web page from your server, and passes it through to the user -- but it also saves the static parts of the page (the image files, CSS, JavaScript and any static web pages). Those elements also get shared on Cloudflares worldwide network of servers. The next time somebody asks for your web page, most of what they get will come from the "nearest" Cloudflare server to them -- only the parts that have changed will come from your web server. That's what gives you the big performance improvement.
Believe it or not, though, that's not why Cloudflare was created. It was intended as a weapon to defend against DoS (denial of service) and DDoS (distributed DoS) attacks. It is only a side effect of their security service that allows the speed-up of your site. To the creators of Cloudflare, it was sort of like if you built a garage, then when you open the door for the first time you find a brand-new Ferrari sitting inside. It's totally cool, and the fact that we're being offered the service here is beyond cool.