What best practices should be followed when integrating third-party scripts and stylesheets in PHP applications?

When integrating third-party scripts and stylesheets in PHP applications, it is important to follow best practices to ensure security and optimal performance. One key practice is to only include scripts and stylesheets from trusted sources to prevent potential security vulnerabilities. Additionally, it is recommended to use a content delivery network (CDN) for commonly used libraries to improve loading times.

// Example of including a third-party script from a CDN
echo '<script src="https://cdn.example.com/script.js"></script>';

// Example of including a third-party stylesheet from a CDN
echo '<link rel="stylesheet" href="https://cdn.example.com/styles.css">';