有没有办法压缩或编译PHP / DHTML / JS组件?

Ok the title may be confusing so I explain here my idea: lets say we have a kind of component for a web page, lets say it is a simple database-driven table or grid. Hypothetically this "component" works standalone, ie, no dependences but relays in a few mixed languages files: html for the design, php for databasing, javascript for interactivity and a few icons images. So normally we would just have all that in a folder we upload and then use it including the main (php and/or js) files.

I wonder is there is at least a theorical way to pack all the files into a single unique file, like a .jar file or something, and use the component like it was an OCX or DLL, whatever. I'm not talking specifically about having all packed for downloading it to the client machine...the idea is more like creating a one file thing that contains all the needed files inside, correctly linked, etc. And then perhaps have one single "include" and some sort of constructor call, etc.

I don't know if this is a stupid question but I'm just wondering that...if we could have DHTML components, visual components, like an editor, a grid, a charting thing, etc, just packed in a single file. In other words, having something like DLLs...

Sure, Your only problem is how you include the images in that file. But, everything is made of bits and bytes, images too. Images can be incorporated into a php file (but this is a separate question). As for html+css+javascript incorporation into one PHP file , I do not see the issue, this is pretty much what every php user is doing.
As whether this is a good practice or not, Well, depends how you build that file.